package day13.thread01;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author Xiao
 * @date 2021/8/5
 */
public class ThreadDemo07 {
    /**
     * Thread类中设置和获取线程优先级的方法：
     * 	public final int getPriority()：获取线程的优先级
     * 	public final void setPriority(int newPriority)：设置线程的优先级
     */
    @SuppressWarnings("all")
    public static void main(String[] args) throws InterruptedException, ExecutionException {
        MyCallable02 mc1 = new MyCallable02();
        MyCallable02 mc2 = new MyCallable02();
        FutureTask<String> ft1 = new FutureTask<>(mc1);
        FutureTask<String> ft2 = new FutureTask<>(mc2);
        Thread t1 = new Thread(ft1);
        Thread t2 = new Thread(ft2);
        t1.setName("阿良");
        t2.setName("左右");
        System.out.println(t1.getPriority());   //5
        System.out.println(t2.getPriority());   //5
        t1.setPriority(6);
        System.out.println(t1.getPriority());   //6
        t1.start();
        t2.start();
    }
}
